package com.powervision.mvvmdemo.ui.viewmodel

import com.powervision.base.base.BaseViewModel
import com.powervision.base.util.LogUtils
import com.powervision.http.observer.StateLiveData
import com.powervision.mvvmdemo.ui.model.ArticleListModel
import com.powervision.mvvmdemo.ui.model.KnowledgeModel
import com.powervision.mvvmdemo.ui.repository.KnowLedgeRepository

/**
 * @auth: njb
 * @date: 2021/12/15 11:53
 * @desc: 描述
 */
class KnowLedgeViewModel :BaseViewModel(){
    private val knowLedgeRepository by lazy { KnowLedgeRepository() }
    val mKnowLiveData = StateLiveData<List<KnowledgeModel.DataBean?>>()

    fun getKnowLedge(){
        launchWithLoading(requestBlock = {
            knowLedgeRepository.knowLedge()
        }, resultCallback = { it ->
            mKnowLiveData.value = it
            it.data?.forEach {
                LogUtils.d("--artlist--", it?.name.toString())
            }
        })
    }
}